package org.boulderfoodrescue.webapp.client.recipients;

import org.boulderfoodrescue.webapp.client.donors.DonorRecipientInterface;

import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;

public class MainRecipientView extends Composite{

  private static MainRecipientViewUiBinder uiBinder = GWT
      .create(MainRecipientViewUiBinder.class);

  interface MainRecipientViewUiBinder extends
      UiBinder<Widget, MainRecipientView> {
  }

  public MainRecipientView(DonorRecipientInterface locInterface) {
    this.locInterface = locInterface;
    locationTable = new RecipientTable(locInterface);
    initWidget(uiBinder.createAndBindUi(this));
  }

  @UiField(provided = true)
  RecipientTable locationTable;
  @UiField
  Button createRecipientButton;
  private DonorRecipientInterface locInterface;

  @UiHandler("createRecipientButton")
  public void onCreateRecipientButtonClick(ClickEvent event)
  {
    if(locInterface != null)
      locInterface.onCreateNewLocationClick();
    else
      Log.error("Pickup Presenter is null");
  }
  
  public RecipientTable getRecipientTable()
  {
    return locationTable;
  }
}
